package com.crm.miaohe.mapper;

import com.crm.miaohe.model.TblInformation;
import com.crm.miaohe.model.TblInformationExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TblInformationMapper {
    long countByExample(TblInformationExample example);

    int deleteByExample(TblInformationExample example);

    @Delete({
        "delete from tbl_information",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into tbl_information (title, summary, ",
        "image, thumb, create_time, ",
        "create_user, update_time, ",
        "update_user, version, ",
        "content)",
        "values (#{title,jdbcType=VARCHAR}, #{summary,jdbcType=VARCHAR}, ",
        "#{image,jdbcType=VARCHAR}, #{thumb,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{createUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{updateUser,jdbcType=VARCHAR}, #{version,jdbcType=BIGINT}, ",
        "#{content,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(TblInformation record);

    int insertSelective(TblInformation record);

    List<TblInformation> selectByExampleWithBLOBs(TblInformationExample example);

    List<TblInformation> selectByExample(TblInformationExample example);

    @Select({
        "select",
        "id, title, summary, image, thumb, create_time, create_user, update_time, update_user, ",
        "version, content",
        "from tbl_information",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("com.crm.miaohe.mapper.TblInformationMapper.ResultMapWithBLOBs")
    TblInformation selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") TblInformation record, @Param("example") TblInformationExample example);

    int updateByExampleWithBLOBs(@Param("record") TblInformation record, @Param("example") TblInformationExample example);

    int updateByExample(@Param("record") TblInformation record, @Param("example") TblInformationExample example);

    int updateByPrimaryKeySelective(TblInformation record);

    @Update({
        "update tbl_information",
        "set title = #{title,jdbcType=VARCHAR},",
          "summary = #{summary,jdbcType=VARCHAR},",
          "image = #{image,jdbcType=VARCHAR},",
          "thumb = #{thumb,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "create_user = #{createUser,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "update_user = #{updateUser,jdbcType=VARCHAR},",
          "version = #{version,jdbcType=BIGINT},",
          "content = #{content,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKeyWithBLOBs(TblInformation record);

    @Update({
        "update tbl_information",
        "set title = #{title,jdbcType=VARCHAR},",
          "summary = #{summary,jdbcType=VARCHAR},",
          "image = #{image,jdbcType=VARCHAR},",
          "thumb = #{thumb,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "create_user = #{createUser,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "update_user = #{updateUser,jdbcType=VARCHAR},",
          "version = #{version,jdbcType=BIGINT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(TblInformation record);
}